﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using RADB;
using System.Web.Script.Serialization;
using System.Collections;

namespace WaiterService
{
    public partial class CheckRole : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentType = "application/x-javascript";
            IDataTransfer DTO = (IDataTransfer)Application["DTO"];
            string logedin = Request["logedin"];

            Hashtable hash = new Hashtable();
            JavaScriptSerializer serializer = (JavaScriptSerializer)Application["serializer"];

            string type = Request["StaffType"];
            int staffID;
            bool result;

            if (logedin != "yes")
                return;

            if (!int.TryParse(Request["StaffID"], out staffID))
                return;

            switch (type)
            {
                case "manager":
                    result = DTO.isManager(staffID);
                    break;
                case "waiter":
                    result = DTO.isWaiter(staffID);
                    break;
                case "host":
                    result = DTO.isHost(staffID);
                    break;
                case "cook":
                    result = DTO.isCook(staffID);
                    break;
                case "busboy":
                    result = DTO.isBusBoy(staffID);
                    break;
                default:
                    return;
            }

            hash.Add("Success", result);
            Response.Output.Write(serializer.Serialize(hash));

        }
    }
}